<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_search" :rules="rules" label-width="100px" id="mvcfm">
      <div class="el-select">
        <el-input v-model="s_search.pro_name" placeholder='工艺名称' />
      </div>
      <el-button @click="getPage(1);" type='primary' size="mini"><i class='fa fa-search'></i>搜索</el-button>
      <el-button @click="popAddTestPlan1('')" type='success' size="mini"><i class='fa fa-plus'></i>增加工艺</el-button>
      <div>
      </div>
      <el-table :data="s_category">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_category('&CMIDcategory_id='+scope.row.category_id+'')">删除</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="popModifyTestPlan('&CMIDcategory_id='+scope.row.category_id+'')">修改</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="popCopyTestPlan('&CMIDcategory_id='+scope.row.category_id+'')">复制工艺</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="工艺名称" prop="category_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/product/PlanDet?CMIDcategory_id='+scope.row.category_id+''+vueparams+'')" type='primary'>{{scope.row.pro_name}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="编制人" prop="contact_name">
        </el-table-column>
        <el-table-column label="编制时间" prop="cdate">
          <template slot-scope="scope">
            {{getDateTimeString(scope.row,'cdate')}}
          </template>
        </el-table-column>
        <el-table-column label="状态" prop="category_state">
          <template slot-scope="scope">
            {{getValueName("启用=1,禁用=0",scope.row.category_state)}}
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog :visible.sync="AddTestPlan1Visible" append-to-body>
      <AddTestPlan1 v-if="AddTestPlan1Visible" ref="AddTestPlan1" :popparams="popparams"> </AddTestPlan1>
    </el-dialog>
    <el-dialog :visible.sync="ModifyTestPlanVisible" append-to-body>
      <ModifyTestPlan v-if="ModifyTestPlanVisible" ref="ModifyTestPlan" :popparams="popparams"> </ModifyTestPlan>
    </el-dialog>
    <el-dialog :visible.sync="CopyTestPlanVisible" append-to-body>
      <CopyTestPlan v-if="CopyTestPlanVisible" ref="CopyTestPlan" :popparams="popparams"> </CopyTestPlan>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import AddTestPlan1 from "@/views/mes/product/AddTestPlan1";
  import ModifyTestPlan from "@/views/mes/product/ModifyTestPlan";
  import CopyTestPlan from "@/views/mes/product/CopyTestPlan";
  export default {
    name: 'TechnologyStatistical',
    components: {
      AddTestPlan1,
      ModifyTestPlan,
      CopyTestPlan,
    },
    props: ['popparams'],
    data() {
      return {
        AddTestPlan1Visible: false,
        AddTestPlan1Value: null,
        AddTestPlan1Desc: null,
        ModifyTestPlanVisible: false,
        ModifyTestPlanValue: null,
        ModifyTestPlanDesc: null,
        CopyTestPlanVisible: false,
        CopyTestPlanValue: null,
        CopyTestPlanDesc: null,
        vueparams: this.getVUEParams("&CMODULEID=pro_category"),
        s_search: {
          pro_name: null,
        },
        s_category: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/technologyStatistical?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_category(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/d_category?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popAddTestPlan1(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AddTestPlan1Visible = !this.AddTestPlan1Visible;
      },
      popModifyTestPlan(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModifyTestPlanVisible = !this.ModifyTestPlanVisible;
      },
      popCopyTestPlan(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.CopyTestPlanVisible = !this.CopyTestPlanVisible;
      },
    },
  }
</script>
